#!/bin/tcsh -f

if ( -s $argv[$#].c ) then
  $*.c -MM | sed 's/\($argv[$#]\)\.o[ :]*/\1.o $argv[$#].d :: /g' > $argv[$#].d
endif
if ( -s $argv[$#].C ) then
  $*.C -MM | sed 's/\($argv[$#]\)\.o[ :]*/\1.o $argv[$#].d :: /g' > $argv[$#].d
endif
if ( -s $argv[$#].cc ) then
  $*.cc -MM | sed 's/\($argv[$#]\)\.o[ :]*/\1.o $argv[$#].d :: /g' > $argv[$#].d
endif
if ( -s $argv[$#].cpp ) then
  $*.cpp -MM | sed 's/\($argv[$#]\)\.o[ :]*/\1.o $argv[$#].d :: /g' > $argv[$#].d
endif

if ( ! -s $argv[$#].d ) then
  rm -f $argv[$#].d
endif
